//
//  WeiboAnnotationView.m
//  01-HZ88微博-架构的搭建
//
//  Created by kangkathy on 16/5/23.
//  Copyright © 2016年 kangkathy. All rights reserved.
//

#import "WeiboAnnotationView.h"
#import "WeiboAnnotation.h"
#import "UIImageView+WebCache.h"

@implementation WeiboAnnotationView

- (instancetype)initWithAnnotation:(id<MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier {
    
    if (self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]) {
        
        
        [self _creatSubViews];
        
    }
    
    return self;
    
    
}



//子视图：用户头像和背景
- (void)_creatSubViews {
    
    UIImageView *bgImgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nearby_map_people.png"]];
    
    [bgImgView sizeToFit];
    
    [self addSubview:bgImgView];
    
    //用户头像
    UIImageView *usrImgView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 7, 50, 50)];
    usrImgView.layer.cornerRadius = 5;
    usrImgView.layer.masksToBounds = YES;
    
    [bgImgView addSubview:usrImgView];
    
    //用户头像的显示
    WeiboAnnotation *weiboAnnotation = (WeiboAnnotation *)self.annotation;
    
    [usrImgView sd_setImageWithURL:[NSURL URLWithString:weiboAnnotation.weibo.user.profile_image_url]];
    
    
    
    
    
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
